package com.px.idal;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import com.px.model.SpeciallistInfo;

/**
 * 定义专家信息操作方法接口
 * */
public interface ISpecialInfoMapper {

	/**
	 * 登录方法
	 * */
	@Select("select * from specialist_info_tb where specialist_name=#{specialist_name} and specialist_pass=#{specialist_pass}")
	public SpeciallistInfo validateSpecialLogin(SpeciallistInfo speciallistInfo);

	/**
	 * 添加专家信息方法
	 * 传参为SpeciallistInfo对象
	 * */
	@Insert("insert into specialist_info_tb(specialist_name,specialist_pass,specialist_realname,professional_title,specialist_contact)value(#{specialist_name},#{specialist_pass},#{specialist_realname},#{professional_title},#{specialist_contact})")
	public int insertSpecialUser(SpeciallistInfo speciallistInfo);

	/**
	 * 指定用户名查询专家帐号方法
	 * 传参为SpeciallistInfo对象
	 * */
	@Select("SELECT count(*) from specialist_info_tb where specialist_name = #{specialist_name}")
	public int checkSpecialNameIsExist(SpeciallistInfo speciallistInfo);

	/**
	 * 指定id查询专家帐号方法
	 * 传参为SpeciallistInfo对象
	 * */
	@Select("SELECT count(*) from specialist_info_tb where specialist_id = #{specialist_id}")
	public int checkSpecialIdIsExist(SpeciallistInfo speciallistInfo);

	/**
	 * 查询专家信息总条数
	 * */
	@Select("select count(*) from specialist_info_tb")
	public int getAllSpecialCounts();

	/**
	 * 专家信息列表查询
	 * */
	@Select("SELECT * from specialist_info_tb")
	public List<SpeciallistInfo> getSpecialInfoList();

	/**
	 * 专家信息列表数据分页查询
	 * */
	@Select("SELECT * from specialist_info_tb LIMIT #{index},#{pagesize}")
	public List<SpeciallistInfo> getSpecialInfoListLimit(@Param("index") int index, @Param("pagesize") int pagesize);

	/**
	 * 单输入框多条件查询分页总数
	 * */
	@Select("SELECT count(*) from specialist_info_tb where specialist_realname like concat(concat('%',#{search}),'%') or specialist_contact LIKE concat(concat('%',#{search}),'%')")
	public int getSpecialCountsBySearch(@Param("search") String search);

	/**
	 * 单输入框多条件查询分页
	 * */
	@Select("SELECT * from specialist_info_tb where specialist_realname like concat(concat('%',#{search}),'%') or specialist_contact LIKE concat(concat('%',#{search}),'%') LIMIT #{index},#{pagesize}")
	public List<SpeciallistInfo> getSpecialInfoBySearchLimit(@Param("search") String search, @Param("index") int index,
			@Param("pagesize") int pagesize);

	/**
	 * 单输入框多条件查询
	 * */
	@Select("SELECT * from specialist_info_tb where specialist_realname like concat(concat('%',#{search}),'%') or specialist_contact LIKE concat(concat('%',#{search}),'%') LIMIT #{index},#{pagesize}")
	public List<SpeciallistInfo> getSpecialInfoBySearch(@Param("search") String search);

	/**
	 * 删除方法
	 * 删除指定specialist_name的专家
	 * */
	@Delete("delete from specialist_info_tb where specialist_name=#{specialist_name}")
	public int deleteSpecialBySpecialName(SpeciallistInfo speciallistInfo);

	/**
	 * 删除方法
	 * 删除指定specialist_id的专家
	 * */
	@Delete("delete from specialist_info_tb where specialist_id=#{specialist_id}")
	public int deleteSpecialBySpecialId(SpeciallistInfo speciallistInfo);

	/**
	 * 更新方法
	 * 更新指定specialist_id的专家信息
	 * */
	@Update("update specialist_info_tb set specialist_name=#{specialist_name},specialist_pass=#{specialist_pass},specialist_realname=#{specialist_realname},professional_title=#{professional_title},specialist_contact=#{specialist_contact} where specialist_id=#{specialist_id}")
	public int updateSpecialBySpecialId(SpeciallistInfo speciallistInfo);

	/**
	 * 更新方法
	 * 更新指定specialist_name的专家信息
	 * */
	@Update("update specialist_info_tb set specialist_name=#{specialist_name},specialist_pass=#{specialist_pass},specialist_realname=#{specialist_realname},professional_title=#{professional_title},specialist_contact=#{specialist_contact} where specialist_name=#{specialist_name}")
	public int updateSpecialBySpecialName(SpeciallistInfo speciallistInfo);

	/**
	 * 指定id查询专家帐号方法
	 * 传参为SpeciallistInfo对象
	 * */
	@Select("SELECT * from specialist_info_tb where specialist_id = #{specialist_id}")
	public List<SpeciallistInfo> getSpecialInfoBySpecialId(SpeciallistInfo speciallistInfo);

}
